<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <button id="home">主页</button>
    <button id="news">新闻</button>
</body>
</html>
<script>
    // history 模式，主要的核心是利用了h5新增的history Api

    // 正常调用pushState也不会建立http连接，发起请求，但是一旦刷新页面就会造成404的问题

    home.onclick = function(){
        history.pushState({name:"路霸"},null,"/home")
    }
    news.onclick = function(){
        history.pushState({name:"狂鼠"},null,"/news")
    }

    // 通过popstate事件处理应对的逻辑
    window.onpopstate = function(e){
        console.log(e);
    }
</script>